<?php

require_once 'include/global.inc.php';

// are we updating the settings ?
if (isset($_POST['submit'])){
	// test the passwords
	$PASS = '';
	if (md5('') != substr($_POST['pwdPassword'], 5){
		if (substr($_POST['pwdPassword'], 5) != substr($_POST['pwdPassword2'], 5)){
			$error = 'those passwords do not match';
		}
		$PASS = " , p_password = '".substr($_POST['pwdPassword'], 5)."' ";
	}

	$query = "
		UPDATE ".T_PLAYER."
		SET p_email = '".sani($_POST['txtEmail'])."'
		{$PASS}
		WHERE p_id = '".sani($_POST['player_id'])."'
	";
	$mysql->query($query, __LINE__, __FILE__);
}

// start the page
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
	"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>iShudan : Settings</title>

	<meta http-equiv="Content-Language" content="en-us" />
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<meta http-equiv="Content-Style-Type" content="text/css" />

	<link rel="stylesheet" href="css/iShudan.css" type="text/css" />

	<script type="text/javascript" src="javascript/md5.js"></script>
	<script type="text/javascript" src="javascript/validate.js"></script>

</head>
<body>
<div id="links"><?php echo $CFG_SITELINKS; ?></div>
<h1>iShudan :: settings</h1>
<p>Hello, <?php echo $_SESSION['username']; ?>.  Please adjust your settings.</p>
<div class="center"><a href="index.php">home</a></div>
<form method="post" action="settings.php" style="margin:10em;" onsubmit="md5pass(true);">
<input type="hidden" name="player_id" value="<?php echo $_SESSION['player_id']; ?>" />
<?php if (isset($error)) { echo '<div class="error">' . $error . '</div>'; } ?>
(leave password fields blank to keep current password)<br />
<input type="password" name="pwdPassword" id="pwdPassword" /> password<br />
<input type="password" name="pwdPassword2" id="pwdPassword2" /> again<br />
<input type="text" name="txtEmail" value="<?php echo $_SESSION['email']; ?>" /> email<br />
<input type="submit" name="submit" value="submit" />
</form>
<div class="center"><a href="index.php?logout">log out</a></div>
<?php call('GLOBALS'); ?>
</body>
</html>
